package com.weiyuwqj.server.service.finance.impl;

import com.github.pagehelper.PageHelper;
import com.weiyuwqj.api.common.PageList;
import com.weiyuwqj.api.common.Paginator;
import com.weiyuwqj.api.model.SysAmountOperate;
import com.weiyuwqj.api.model.vo.ManageAmountDetailsVO;
import com.weiyuwqj.api.model.vo.StatAmountDetailsVO;
import com.weiyuwqj.api.service.SysAmountOperateService;
import com.weiyuwqj.server.mapper.SysAmountOperateMapper;
import com.weiyuwqj.server.service.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/4/26.
 */
@Service("sysAmountOperateService")
public class SysAmountOperateServiceImpl extends BaseServiceImpl<SysAmountOperate> implements SysAmountOperateService {

    @Autowired
    private SysAmountOperateMapper operateMapper;

    //资金明细管理列表分页查询
    @Override
    public PageList getAmountDetailsList(Paginator p, ManageAmountDetailsVO detailsVO) {
        PageHelper.startPage(p.getPageNum(), p.getPageSize());
        List<ManageAmountDetailsVO> list = operateMapper.getAmountDetailsList(detailsVO);
        return new PageList(list);
    }

    //资金明细管理列表不分页查询
    @Override
    public List<ManageAmountDetailsVO> getAmountDetailsList(ManageAmountDetailsVO detailsVO) {
        return operateMapper.getAmountDetailsList(detailsVO);
    }

    @Override
    public StatAmountDetailsVO statAmountDetails(ManageAmountDetailsVO detailsVO) {
        StatAmountDetailsVO amountDetailsVO = operateMapper.statIncome(detailsVO);
//        amountDetailsVO.setStatBalance(operateMapper.statBalance(detailsVO).getStatBalance());
        amountDetailsVO.setStatExpend(operateMapper.statExpend(detailsVO).getStatExpend());
        amountDetailsVO.setStatCount(operateMapper.statCount(detailsVO).getStatCount());
        return amountDetailsVO;
    }
}
